import HttpUtils from '../HttpUtils/HttpUtils';
// 获取当前时间戳
var timestamp = Date.parse(new Date()) / 1000;
Page({
	...HttpUtils.func,
	data: {
		videoPageConst: {
			//红色影视栏目ID
			redColumnId: 8161,
			//党建视频栏目ID
			tvColumnId: 8140,
			//热门标签栏目ID
			topSignColumnId: 8141,
		},
		redColumnList: [],
		tvColumnList: [],
		topSignColumnList: [],
	},
	onLoad() {
		console.log("进入视频资源菜单");
		//加载红色影视栏目下内容
		this.loadRedColumnList();
	},

	//红色影视
	loadRedColumnList: function(e) {
		//加载栏目下内容
		var folderCode = this.data.videoPageConst.redColumnId;
		var newUrl = getApp().globalData.dangjianUrl + "/content/relativeFolderQuery";
	  var params = {};
		params["pageIndex"] = "1";
		params["pageItems"] = "2";
		params["code"] = folderCode + '';
		params["siteCode"] = getApp().globalData.siteCode + "";
		params = JSON.stringify(params);

		this.httpGet(newUrl, params, "子栏目加载失败").then(
			(respData) => {
				var result = respData.data.result.code;
				if (1 == result) {
					var folders = respData.data.folders.folder;
					this.setData({
						"redColumnList": folders
					});
        } else {
          this.showPageMsg("alert", respData.data.result.description) 
				}
				this.loadtvColumnList(this.data.videoPageConst.tvColumnId);
			}
		);
	},

	//党建视频
	loadtvColumnList: function(parentId) {
		//加载栏目下内容 
		var newUrl = getApp().globalData.dangjianUrl + "/content/relativeFolderQuery";
	 	var params = {};
		params["pageIndex"] = "1";
		params["pageItems"] = "4";
		params["code"] = parentId + '';
		params["siteCode"] = getApp().globalData.siteCode + "";
		params = JSON.stringify(params);
		this.httpGet(newUrl, params, "子栏目加载失败").then(
			(respData) => {
				var result = respData.data.result.code;
				if (1 == result) {
					var folders = respData.data.folders.folder;
					this.setData({
						"tvColumnList": folders
					});
        } else {
          this.showPageMsg("alert", respData.data.result.description) 
				}
				this.loadtopSignColumnList(this.data.videoPageConst.topSignColumnId)
			}
		);
	},

	//热门标签
	loadtopSignColumnList: function(parentId) {
		//加载栏目下内容 
		var newUrl = getApp().globalData.dangjianUrl + "/content/relativeFolderQuery";
	  var params = {};
		params["pageIndex"] = "1";
		params["pageItems"] = "100";
		params["code"] = parentId + '';
		params["siteCode"] = getApp().globalData.siteCode + "";
		params = JSON.stringify(params);

		this.httpGet(newUrl, params, "子栏目加载失败").then(
			(respData) => {
				var result = respData.data.result.code;
				if (1 == result) {
					var folders = respData.data.folders.folder;
					this.setData({
						"topSignColumnList": folders
					});
				} else {
					wx.alert({ title: respData.data.result.description });
				}
			}
		);
	},

	//视频搜索
	searchSubmit(event) {                  //点击键盘完成  
		wx.navigateTo({
			url: '../videoSearch/videoSearch?keyword=' + event.detail.value,
		})
	},

	// 电影跳转 电视剧跳转
	goMoviePage(event) {
		var folderCode = event.currentTarget.dataset.code;
		wx.navigateTo({
			url: '../movie/movie?folderCode=' + folderCode
		})
	},

	shortVideo(e) {  // 热门标签
		var folderCode = e.currentTarget.dataset.code;
		wx.navigateTo({
			url: '../shortVideo/shortVideo?folderCode=' + folderCode
		})
	}
});
